from selenium import webdriver
import time

# driver = webdriver.Chrome("C:/Users/EDZ/AppData/Local/Google/Chrome/Application/chromedriver.exe")

# 声明浏览器
browser = webdriver.Chrome()

# 找到html文件并打开
Path_name = 'D:/Python学习-100天/Day49/selenium.html'

browser.get(Path_name)

# 查找元素并操作
time.sleep(2)
User_name = browser.find_element_by_css_selector('[name="username"]').send_keys('rabbit')
time.sleep(2)
Pass_word = browser.find_element_by_css_selector('[name="password"]').send_keys('love')
time.sleep(2)
Confirm_button = browser.find_element_by_css_selector('#sub').click()
time.sleep(2)


# 标题和url
print(browser.title)
print(browser.current_url)

# 关闭浏览器
browser.quit()